package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.model.user.UserInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 李旭
 * @Time: 15:45
 * @Description:
 */
@Controller
@RequestMapping("/hello")
public class HelloController {

    //后端的页面渲染
    @GetMapping("/h")
    public String h(Model model, HttpSession session){
        model.addAttribute("world","世界你真好");

        List<String> list = new ArrayList<>();
        list.add("刘血块");
        list.add("溶胶");
        list.add("关晓同");
        model.addAttribute("list",list);

        UserInfo userInfo = new UserInfo();
        userInfo.setName("小小猪");
        model.addAttribute("userInfo",userInfo);
        session.setAttribute("sessionValue","我是Session中的值");

        model.addAttribute("gname","<span style=\"color:green\">宝强</span>");
        return "hello";
    }
}
